#!/usr/bin/env python
# encoding: utf-8
'''
@author: YanYeek
@file: menu.py
@time: 2020/8/23 20:53
@desc:
'''
from django import forms
from django.utils.safestring import mark_safe
from rbac import models
from rbac.forms.base import BootStrapModelForm

ICON_LIST = [
	['fa-hand-scissors-o', '<i aria-hidden="true" class="fa fa-hand-scissors-o"></i>'],
	['fa-hand-spock-o', '<i aria-hidden="true" class="fa fa-hand-spock-o"></i>'],
	['fa-hand-stop-o', '<i aria-hidden="true" class="fa fa-hand-stop-o"></i>'],
	['fa-handshake-o', '<i aria-hidden="true" class="fa fa-handshake-o"></i>'],
	['fa-hard-of-hearing', '<i aria-hidden="true" class="fa fa-hard-of-hearing"></i>'],
	['fa-hashtag', '<i aria-hidden="true" class="fa fa-hashtag"></i>'],
	['fa-hdd-o', '<i aria-hidden="true" class="fa fa-hdd-o"></i>'],
	['fa-headphones', '<i aria-hidden="true" class="fa fa-headphones"></i>'],
	['fa-heart', '<i aria-hidden="true" class="fa fa-heart"></i>'],
	['fa-heart-o', '<i aria-hidden="true" class="fa fa-heart-o"></i>'],
	['fa-heartbeat', '<i aria-hidden="true" class="fa fa-heartbeat"></i>'],
	['fa-history', '<i aria-hidden="true" class="fa fa-history"></i>'],
	['fa-home', '<i aria-hidden="true" class="fa fa-home"></i>'],
	['fa-hotel', '<i aria-hidden="true" class="fa fa-hotel"></i>'],
	['fa-hourglass', '<i aria-hidden="true" class="fa fa-hourglass"></i>'],
	['fa-hourglass-1', '<i aria-hidden="true" class="fa fa-hourglass-1"></i>'],
	['fa-hourglass-2', '<i aria-hidden="true" class="fa fa-hourglass-2"></i>'],
	['fa-hourglass-3', '<i aria-hidden="true" class="fa fa-hourglass-3"></i>'],
	['fa-hourglass-end', '<i aria-hidden="true" class="fa fa-hourglass-end"></i>'],
	['fa-hourglass-half', '<i aria-hidden="true" class="fa fa-hourglass-half"></i>'],
	['fa-hourglass-o', '<i aria-hidden="true" class="fa fa-hourglass-o"></i>'],
	['fa-hourglass-start', '<i aria-hidden="true" class="fa fa-hourglass-start"></i>'],
	['fa-i-cursor', '<i aria-hidden="true" class="fa fa-i-cursor"></i>'],
	['fa-id-badge', '<i aria-hidden="true" class="fa fa-id-badge"></i>'],
	['fa-id-card', '<i aria-hidden="true" class="fa fa-id-card"></i>'],
	['fa-id-card-o', '<i aria-hidden="true" class="fa fa-id-card-o"></i>'],
	['fa-image', '<i aria-hidden="true" class="fa fa-image"></i>'],
	['fa-mail-reply-all', '<i aria-hidden="true" class="fa fa-mail-reply-all"></i>'],
	['fa-reply', '<i aria-hidden="true" class="fa fa-reply"></i>'],
	['fa-reply-all', '<i aria-hidden="true" class="fa fa-reply-all"></i>'],
	['fa-retweet', '<i aria-hidden="true" class="fa fa-retweet"></i>'],
	['fa-wrench', '<i aria-hidden="true" class="fa fa-wrench"></i>']]
for item in ICON_LIST:
	item[1] = mark_safe(item[1])


class MenuModelForm(forms.ModelForm):
	class Meta:
		model = models.Menu
		fields = {'title', 'icon'}
		widgets = {
			'title': forms.TextInput(attrs={'class': 'form-control'}),
			'icon': forms.RadioSelect(
				choices=ICON_LIST,
				attrs={'class': 'clearfix'},
			)
		}


class SecondMenuModelForm(BootStrapModelForm):
	class Meta:
		model = models.Permission
		exclude = ['pid']

class PermissionModelForm(BootStrapModelForm):
	class Meta:
		model = models.Permission
		fields = ['title', 'name', 'url']
